#pragma once

#include "CreateLinkObjectAction.h"

#include "OutputPin.h"

namespace uml {

CreateLinkObjectAction::CreateLinkObjectAction(const QString& umlType)
    : CreateLinkAction(umlType) {}

void CreateLinkObjectAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    CreateLinkAction::fromJson(json, errorList);
    result_ = JsonSerializable::create<OutputPin>(json.value("result"), errorList);

}

void CreateLinkObjectAction::toJson(QJsonObject& json) {
    CreateLinkAction::toJson(json);
    if (result_) {
        QJsonObject result_json;
        result_->toJson(result_json);
        json.insert("result", result_json);
    }
}

/// <summary>
/// result getter
/// The output pin on which the newly created link object is placed.
/// </summary>
shared_ptr<OutputPin> CreateLinkObjectAction::result() const {
    return result_;
}

/// <summary>
/// result setter
/// The output pin on which the newly created link object is placed.
/// </summary>
void CreateLinkObjectAction::setResult(shared_ptr<OutputPin> value) {
    result_ = value;
}

} // namespace uml
